package com.nulldev.util.web.HttpServer3.extensions.websocket.util;

import com.nulldev.util.web.HttpServer3.extensions.websocket.exceptions.InvalidFrameException;
import com.nulldev.util.web.HttpServer3.extensions.websocket.frame.Frame;
import com.nulldev.util.web.HttpServer3.extensions.websocket.frame.FrameType;

public class FrameUtils {
	public static boolean isControlFrame(Frame frame) {
		return isControlFrame(frame.getFrameType());
	}

	public static boolean isControlFrame(FrameType frameType) {
		int type = frameType.getByte();
		if (type >= 0 && type <= 7)
			return false;
		if (type >= 8 && type <= 15)
			return true;
		throw new InvalidFrameException();
	}
}
